package ZuoYe01_LeiyuDuiXiang_0428;

import java.util.Scanner;

//更改管理员密码那题：
// 模拟实现用户密码管理：输入旧的用户名和密码，如果正确，方有权限更新；
// 从键盘获取新的密码，进行更新
public class MiMa {

	String account = "admin";
	String password = "123456";

	public void changePassword() {

		while (true) {
			Scanner input = new Scanner(System.in);
			MiMa a = new MiMa();
			System.out.print("请输入您的账号：");
			a.account = input.next();
			System.out.print("请输入您的密码：");
			a.password = input.next();

			if (a.account.equals(account) && a.password.equals(password)) {
				System.out.print("请输入新密码：");
				String password2 = input.next();
				System.out.print("请再次输入新密码：");
				String password3 = input.next();
				if (password2.equals(password3)) {
					password = password2;
					System.out.println("密码重置成功，新密码是：" + password);
					break;
				} else {
					System.out.println("两次输入密码不一致，密码重置失败！");
				}
			} else {
				System.out.println("账号或密码输入错误，请重新输入！");
			}
		}
	}

	public static void main(String[] args) {
		MiMa b = new MiMa();
		b.changePassword();

	}

}
